angular.module("app.my").register.controller('MyProfileCtrl', ["$scope", "$http", "$document", "$modalService", function($scope, $http, $document, $modalService){
  $scope.loader = function(){
    $http.post('/my/index/detail').success(function(ret){
      if(ret.status){
        $scope.entity = ret.data;
      }else{
        $modalService.myAlert(ret.data);
      }
    }).error(function(){
      $modalService.myAlert('系统错误，请求资源失败！');
    });
  };
  $scope.loader();
}]);
angular.module("app.my").register.controller('MyResetPasswordCtrl', ["$scope", "$http", "$document", "$modalService", function($scope, $http, $document, $modalService){
  $scope.entity = {};
  $scope.loader = function(){
    $http.post('/my/index/get').success(function(ret){
      if(ret.status){
        $scope.entity = {
          'account': ret.data.account,
          'name': ret.data.name,
          'old_password': '',
          'new_password': '',
          'new_password2': ''
        };
      }else{
        $modalService.myAlert(ret.data);
      }
    }).error(function(){
      $modalService.myAlert('系统错误，请求资源失败！');
    });
  };
  $scope.submit = function(){
    $http.post('/my/index/resetpassword/', $scope.entity, {
      transformRequest: function(data){
        return $.param(data);
      }
    }).success(function(ret){
      if(ret.status){
        $modalService.myAlert(ret.data);
      }else{
        $modalService.myAlert(ret.data);
      }
    }).error(function(){
      $modalService.myAlert('系统错误，请求资源失败！');
    });
  };
  $scope.loader();
}]);
angular.module("app.my").register.controller('MyResetMessageCtrl', ["$scope", "$http", "$document", "$modalService", function($scope, $http, $document, $modalService){
  $scope.entity = {};
  $scope.loader = function(){
    $http.post('/my/index/get').success(function(ret){
      if(ret.status){
        $scope.entity = {
          'account': ret.data.account,
          'name': ret.data.name,
          'mobile': ret.data.mobile,
          'tel': ret.data.tel,
          'email': ret.data.email
        };
      }else{
        $modalService.myAlert(ret.data);
      }
    }).error(function(){
      $modalService.myAlert('系统错误，请求资源失败！');
    });
  };
  $scope.submit = function(){
    $http.post('/my/index/resetprofile/', $scope.entity, {
      transformRequest: function(data){
        return $.param(data);
      }
    }).success(function(ret){
      if(ret.status){
        $modalService.myAlert(ret.data);
      }else{
        $modalService.myAlert(ret.data);
      }
    }).error(function(){
      $modalService.myAlert('系统错误，请求资源失败！');
    });
  };
  $scope.loader();
}]);

